<template>
	<view class="content">
		<view class="mt20 flex1 flex-row">
			<view class="s_width">手机号：</view>
			<input class="flex1" type="number" placeholder="请输入手机号" />
		</view>
		<view class="mt20 flex1 flex-row">
			<view class="s_width">验证码：</view>
			<input class="flex1" type="number" placeholder="请输入验证码" />
			<button class="vCode" type="primary" v-show="show" @click="getCode">获取验证码</button>
			<view class="vCode vCodeTime" v-show="!show">{{count}} s</view>
		</view>
		<button class="submit" @click="submit" type="primary">提交</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: true,
				count: '',
				timer: null,
			}
		},
		onLoad() {

		},
		methods: {
			getCode() {
				const TIME_COUNT = 60;
				if (!this.timer) {
					this.count = TIME_COUNT;
					this.show = false;
					this.timer = setInterval(() => {
						if (this.count > 0 && this.count <= TIME_COUNT) {
							this.count--;
						} else {
							this.show = true;
							clearInterval(this.timer);
							this.timer = null;
						}
					}, 1000)
				}
			},
			submit(){
				uni.navigateTo({
					url: '/pages/index/index',
				});
			}
		}
	}
</script>

<style>
	.content {
		width: 80%;
		margin-left: auto;
		margin-right: auto;
		padding-top: 20rpx;
		font-size: 26rpx;
	}

	.submit {
		margin-top: 40rpx;
	}

	.vCode {
		width: 180rpx;
		height: 60rpx;
		font-size: 26rpx;
		line-height: 60rpx;
		border-radius: 16rpx;
	}
	.vCodeTime{
		background-color: #F1F1F1;
		text-align: center;
	}
	.mt20 {
		margin-top: 20rpx;
	}

	.flex1 {
		flex: 1;
		word-wrap: break-word;
		word-break: break-all;
	}

	.flex-row {
		-webkit-display: flex;
		display: flex;
		flex-direction: row;
		-webkit-align-items: center;
		align-items: center;
		-webkit-justify-content: center;
		justify-content: center;
	}

	.s_width {
		width: 160rpx;
	}
</style>
